package com.k8sops.backend.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * Docker镜像仓库配置类
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "docker")
public class DockerRegistryConfig {

    private Map<String, RegistryConfig> registry;

    /**
     * 获取阿里云Docker仓库配置
     * @return 阿里云Docker仓库配置
     */
    public RegistryConfig getAliyunRegistry() {
        return registry != null ? registry.get("aliyun") : null;
    }

    /**
     * 根据名称获取Docker仓库配置
     * @param name 仓库名称
     * @return Docker仓库配置
     */
    public RegistryConfig getRegistryByName(String name) {
        return registry != null ? registry.get(name) : null;
    }

    /**
     * Docker仓库配置
     */
    @Data
    public static class RegistryConfig {
        private String url;
        private String username;
        private String password;
        private String email;
    }
}
